﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace BuyTicket.Models
{
    class Station
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="englishName">英文站点名</param>
        /// <param name="chineseName">中文站点名</param>
        /// <param name="queryName">查询名</param>
        /// <param name="number">序号</param>
        public Station(string englishName,
            string chineseName,
            string queryName,
            string number)
        {
            this.EnglishName = englishName;
            this.ChineseName = chineseName;
            this.QueryName = queryName;
            this.Number = number;
        }

        /// <summary>
        /// 英文站点名
        /// </summary>
        public string EnglishName { get; set; }

        /// <summary>
        /// 中文站点名
        /// </summary>
        public string ChineseName { get; set; }

        /// <summary>
        /// 查询关键字
        /// </summary>
        public string QueryName { get; set; }

        /// <summary>
        /// 序号
        /// </summary>
        public string Number { get; set; }

        /// <summary>
        /// 根据原Js格式创建
        /// </summary>
        /// <param name="line">一行数据</param>
        /// <returns>Station信息</returns>
        public static Station Create(string line)
        {
            string[] sArry = Regex.Split(line.Replace('|', ','), ",");
            if (sArry.Length != 4)
            {
                throw new ArgumentException("line");
            }
            return new Station(sArry[0], sArry[1], sArry[2], sArry[3]);
        }
    }
}
